<%--
  Created by IntelliJ IDEA.
  User: 周文涛
  Date: 2020/7/22
  Time: 15:09
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>订单管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/back/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/back/layuiadmin/style/admin.css" media="all">
</head>
<body>

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">订单号</label>
                    <div class="layui-input-inline">
                        <input type="text" name="ordersId" placeholder="请输入" autocomplete="off" class="layui-input">
                    </div>
                </div>

                <div class="layui-inline">
                    <label class="layui-form-label">电影名</label>
                    <div class="layui-input-inline">
                        <input type="text" name="filmName" placeholder="请输入" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">订单状态</label>
                    <div class="layui-input-inline">
                        <select name="ordersStatus">
                            <option value="">全部</option>
                            <option value="0">未支付</option>
                            <option value="1">已支付</option>
                            <option value="2">已完成</option>
                            <option value="3">已退单</option>
                            <option value="4">已超时</option>
                        </select>
                    </div>
                </div>

            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">用户名</label>
                    <div class="layui-input-inline">
                        <input type="text" name="accountName" placeholder="请输入" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">开始时间</label>
                    <div class="layui-input-inline">
                        <input type="text" id="startTime" name="startTime" class="layui-input" placeholder="开始时间">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">结束时间</label>
                    <div class="layui-input-inline" class="layui-input">
                        <input type="text" id="endTime" name="endTime" class="layui-input" placeholder="结束时间">
                    </div>
                </div>
                <div class="layui-inline">
                    <button class="layui-btn layuiadmin-btn-list" lay-submit lay-filter="search">
                        <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                    </button>
                </div>
            </div>
        </div>

        <div class="layui-card-body">
            <table id="orders_list" lay-filter="orders_list"></table>
            <script type="text/html" id="table-content-list">
                <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="details"><i class="layui-icon layui-icon-edit"></i>查看详情</a>
            </script>
        </div>
    </div>
</div>

<script src="${pageContext.request.contextPath}/back/layuiadmin/layui/layui.js"></script>

<script type="text/javascript">

</script>
<script>
    layui.config({
        base: '${pageContext.request.contextPath}/back/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['table','laydate','form'], function(){
        var table = layui.table,
            laydate = layui.laydate,
            form = layui.form,
            $ = layui.$;
        var cols = [[ //表头
            {field: 'ordersId', title: '订单编号', sort: true, width:180, fixed: 'left'}
            ,{field: 'accountName', title: '用户名称', sort: true, width:120,templet:'<div>{{d.account.accountName}}</div>'}
            ,{field: 'auditoriumsName', title: '影厅名称', sort: true, width:120,templet:'<div>{{d.screening.auditoriums.auditoriumsName}}</div>'}
            ,{field: 'screeningStartTime', title: '场次开始时间', sort: true, width: 150,templet:'<div>{{d.screening.screeningStartTime}}</div>'}
            ,{field: 'filmName', title: '电影名称', width: 160, sort: true,templet:'<div>{{d.screening.film.filmName}}</div>'}
            ,{field: 'ordersTime', title: '下单时间', width:160, sort: true}
            ,{field: 'payType', title: '支付方式', sort: true, width: 120}
            ,{field: 'payPrice', title: '支付价格', sort: true, width: 120}
            ,{field: 'ordersStatus', title: '订单状态', sort: true, width: 120,templet:function(data){
                    var status = data.ordersStatus;
                    if(status == 0){
                        return "未支付";
                    }else if(status == 1){
                        return "已支付";
                    }else if(status == 2){
                        return "已完成";
                    }else if(status == 3){
                        return "已退款";
                    }else if(status == 4){
                        return "已超时";
                    }
                }}
            ,{field: '', title: '操作', width: 200,toolbar:"#table-content-list"}

        ]];

        table.render({
            elem: '#orders_list'
            ,url: '${pageContext.request.contextPath}/back/orders' //数据接口
            ,page: true //开启分页
            ,cols: cols
            ,parseData:function(res){
                return {
                    "code": 0, //解析接口状态
                    "msg": "搜索成功", //解析提示文本
                    "count": res.total, //解析数据长度
                    "data": res.list, //解析数据列表
                };
            }
        });

        form.on('submit(search)',function(data){
            var field = data.field;
            layer.msg("正在搜索");
            table.render({
                elem: '#orders_list'
                ,url: '${pageContext.request.contextPath}/back/orders' //数据接口
                ,where: field
                ,page: true //开启分页
                ,cols: cols
                ,parseData:function(res){
                    return {
                        "code": 0, //解析接口状态
                        "msg": "", //解析提示文本
                        "count": res.total, //解析数据长度
                        "data": res.list, //解析数据列表
                    };
                }
            });
        });

        laydate.render({
            elem: '#startTime' //指定元素
            ,type:'datetime'
        });
        laydate.render({
            elem: '#endTime' //指定元素
            ,type:'datetime'
        });

        table.on('tool(orders_list)',function(obj){
            var ordersId = obj.data.ordersId;
            if(obj.event == 'details'){
                layer.open({
                    type: 2
                    ,title:"查看订单详情"
                    ,content:"${pageContext.request.contextPath}/back/views/order/ordersDetails.jsp?ordersId="+ordersId
                    ,area: ['550px', '550px']
                    ,btn: ['确定', '取消']
                });


            }
        });

    });
</script>
</body>
</html>

